<template>
  <div>
    <Upload :fileType="fileType" :fileCounts="20" :fileM="1024*1024*10" v-model="imageList" :getImageListFn="getImageList" :imgList="imgList"/>
    <div class="information-btn">
      <el-button type="primary" @click="save" >保存</el-button>
      <el-button type="primary" @click="back">返回</el-button>
    </div>
  </div>
</template>
<script>
import Upload from '@/components/common/Upload.vue'
import {imageAdd,getImglist} from '@/public/js/room.js'
export default {
  components: {
    Upload
  },
  data () {
    return {
      fileType: ['jpg', 'jpeg', 'png', 'bmp'],
      UuidListL: [],
      imageList: [],
      photoId:'',
      imgList:[]
    }
  },
  created () {
    sessionStorage.setItem('last', true)
    this.photoId = this.$route.query.id
    this.getImageList()
  },
  methods: {
    back () {
      this.$router.go(-1)
    },
    getImageList(){
      getImglist({id:this.photoId}).then(res=>{
        if(!res.data.errCode) {
          this.imgList = res.data.hotelPictureList
        }
      })
    },
    // 保存
    save () {
      //this.sendChange()
      imageAdd({
        "photoId": this.photoId,
        "hotelPictureList":this.imageList
      }).then(res=>{
        if(!res.data.errCode) {
          this.$message({
            type:'success',
            message:'操作成功'
          })
          this.$router.go(-1)
        }
      })
    },
    
  }
}
</script>
<style lang="scss">
.information-btn {
  .el-button--primary {
    width: 82px;
    height: 34px;
    padding: 0px;
  }
}
</style>


